package title;

import java.util.Scanner;

/**
 * 功能：
 * 作者：lc
 * 日期：2024/11/25 20:23
 */
public class Main1003 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int N=1000005;
        int ans=-1;
        int n = scanner.nextInt();
        int[] a=new int[N];
        int[] b=new int[N];
        int[] g=new int[N];
        int[] k=new int[N];
        for (int i = 1; i <= n; i++) {
            a[i]= scanner.nextInt();
            b[i]= scanner.nextInt();
            g[i]= scanner.nextInt();
            k[i]= scanner.nextInt();
        }
        int x=scanner.nextInt();
        int y=scanner.nextInt();
        for (int i = 1; i <=n; i++) {
           if((a[i]+g[i]>=x&&x>=a[i])&&(b[i]+k[i]>=y&&y>=b[i]))
               ans=i;
        }
        System.out.println(ans);

    }
}
